package org.yonggan.dmp.graphx

import org.apache.commons.lang3.StringUtils
import org.apache.spark.sql.Row

object UserIdentity {

  /**
    * 用户标识标签
    *
    * @param agrs
    * @return List[(String,Int)]  标签集合
    */
  def allUserId(agrs: Any*): List[(String)] = {

    val row = agrs(0).asInstanceOf[Row]

    var lst = List[(String)]()

    if (StringUtils.isNotEmpty(row.getAs[String]("imei"))) lst :+= "IM#" + row.getAs[String]("imei")
    if (StringUtils.isNotEmpty(row.getAs[String]("mac"))) lst :+= "MC#" + row.getAs[String]("mac")
    if (StringUtils.isNotEmpty(row.getAs[String]("idfa"))) lst :+= "IF#" + row.getAs[String]("idfa")
    if (StringUtils.isNotEmpty(row.getAs[String]("openudid"))) lst :+= "PU#" + row.getAs[String]("openudid")
    if (StringUtils.isNotEmpty(row.getAs[String]("androidid"))) lst :+= "AD#" + row.getAs[String]("androidid")

    if (StringUtils.isNotEmpty(row.getAs[String]("imeimd5"))) lst :+= "IMM#" + row.getAs[String]("imeimd5")
    if (StringUtils.isNotEmpty(row.getAs[String]("macmd5"))) lst :+= "MCM#" + row.getAs[String]("macmd5")
    if (StringUtils.isNotEmpty(row.getAs[String]("idfamd5"))) lst :+= "IFM#" + row.getAs[String]("idfamd5")
    if (StringUtils.isNotEmpty(row.getAs[String]("openudidmd5"))) lst :+= "PUM#" + row.getAs[String]("openudidmd5")
    if (StringUtils.isNotEmpty(row.getAs[String]("androididmd5"))) lst :+= "ADM#" + row.getAs[String]("androididmd5")

    if (StringUtils.isNotEmpty(row.getAs[String]("imeisha1"))) lst :+= "IMS#" + row.getAs[String]("imeisha1")
    if (StringUtils.isNotEmpty(row.getAs[String]("macsha1"))) lst :+= "MCS#" + row.getAs[String]("macsha1")
    if (StringUtils.isNotEmpty(row.getAs[String]("idfasha1"))) lst :+= "IFS#" + row.getAs[String]("idfasha1")
    if (StringUtils.isNotEmpty(row.getAs[String]("openudidsha1"))) lst :+= "PUS#" + row.getAs[String]("openudidsha1")
    if (StringUtils.isNotEmpty(row.getAs[String]("androididsha1"))) lst :+= "ADS#" + row.getAs[String]("androididsha1")

    lst
  }

}
